home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
program
/
swags_z.zip
/
SOUND.SWG
/
0028_Sounds In Pascal.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-08-27
|
544b
|
29 lines
{
JOERGEN DORCH
About Sounds i Pascal - Here's how I do it:
}
Function Frequency(Octave, NoteNum : Integer) : Integer;
Const
Silence = 32767;
Var
Oct : Integer;
Function Power(X, Y : Real) : Real;
begin
Power := Exp(Y * Ln(X));
end;
begin
Oct := Octave - 3;
if NoteNum > 0 then
Frequency := Round(440 * Power(2, Oct + ((NoteNum - 10) / 12)))
else
Frequency := Silence;
end;
{
Where Octave is in the range [0..6] and NoteNum in the range [1..12],
that is C = 1, C# = 2, D = 3 etc.
}